package edu.sctu.practice.class01.fengleilin.assign03.test03;

/**
 * Created by fll on 2015/10/22.
 */

import javax.lang.model.element.*;
import java.lang.*;

/**
 * CloneableCircle类是Circle类的子类，并实现了Cloneable接口
 */
public class CloneableCircle extends Circle implements Cloneable{

    public Name getCreator() {
        return creator;
    }

    public void setCreator(Name creator) {
        this.creator = creator;
    }

    public Name creator;//代表圆对象的创建者姓名

    /**
     * 实现clone方法，以实现两个CloneableCircle类对象内容的克隆。要求实现对象内容深拷贝(深复制)
     * @return
     * @throws CloneNotSupportedException
     */
    @Override
    protected Object clone() throws CloneNotSupportedException {

        CloneableCircle circle = (CloneableCircle) super.clone();
        circle.setCreator((Name) circle.getCreator().clone());
        return super.clone();
    }
}
